<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>{$Goods['title']} - {:config('web.WEB_TIT')}</title>
<meta name="keywords" content="{:config('web.WEB_KEY')}">
<meta name="description" content="{:config('web.WEB_DES')}">
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black"> 
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<link href="__ROOT__/favicon.ico" rel="icon" type="image/x-icon"/>
<link rel="stylesheet" href="__ADMIN__/layui/css/layui.css" media="all">
<link rel="stylesheet" href="__MOBILE__/css/home.css" media="all">
<script src="__MOBILE__/mods/jquery-1.10.2.min.js" charset="utf-8"></script>
<script src="__ADMIN__/layui/layui.js" charset="utf-8"></script>
<style>
html, body{height: 100%;}
.layui-main{max-width: 1024px;width: 97%;}
.layui-flow-more {display: inline-block;width: 100%;}
.layui-flow-more a cite{margin: 20px 0 80px 0;}
.layui-fixbar{bottom: 70px;}
.layui-layer{max-width: 1024px;}
.go_tip img{width: 100%;margin: 0px;border: none;}
</style>
</head>
<body class="site-home" id="LAY_home">
<div id="header" class="layui-header header" style="position: fixed;background: none;">
  <div class="go-back" style="width: 35px;height: 35px;margin: 8px;border-radius: 35px;background: #555;"><a href="javascript:;" onClick="javascript :history.back(-1);" style="height: 35px;line-height: 37px;"><i class="layui-icon" style="font-size: 18px;">&#xe603;</i></a></div>
</div>
<div id="layerOpen" class="go_tip" style="text-align: center;">
  <img id="tip_pic" src="" alt="" onclick="history.go(-1)">
  <span id="tip_text" style="display: none;">
    温馨提示：
    <br>
    有【手机淘宝app】的选择淘口令购买方式更方便哦~    
  </span>
  <a href="javascript:;" id="tip_taoToken" class="LAY_layuipro" data-method="notice" style="display: none;"><i class="layui-icon">&#xe63a;</i>淘口令购买</a>
</div>
<if condition="$Goods.clickUrl eq ''">
<div style="visibility:hidden;" >
 <a data-type="0" biz-itemid="{$Goods.numIid}" data-style="2"  data-tmpl="230x312" style="visibility:hidden;"></a>
</div>
<script type="text/javascript">
(function(win,doc){
    var s = doc.createElement("script"), h = doc.getElementsByTagName("head")[0];
    if (!win.alimamatk_show) {
        s.charset = "gbk";
        s.async = true;
        s.src = "http://a.alimama.cn/tkapi.js";
        h.insertBefore(s, h.firstChild);
    };
    var o = {
        pid: "{$pid}",
        appkey: "",
        unid: ""
    };
    win.alimamatk_onload = win.alimamatk_onload || [];
    win.alimamatk_onload.push(o);
})(window,document);
</script>
<script language="javascript">
var itemUrl = 'http://detail.tmall.com/item.htm?id={$Goods.numIid}';
var url='';
var timer;
function get_et(){
  var s = new Date(),
  l = +s / 1000 | 0,
  r = s.getTimezoneOffset() * 60,
  p = l + r,
  m = p + (3600 * 8),
  q = m.toString().substr(2, 8).split(""),
  o = [6, 3, 7, 1, 5, 2, 0, 4],
  n = [];
  for (var k = 0; k < o.length; k++) {
    n.push(q[o[k]]);
  }
  n[2] = 9 - n[2];
  n[4] = 9 - n[4];
  n[5] = 9 - n[5];
  return n.join("");
}
function setCookie(j, k){
  document.cookie = j + "=" + encodeURIComponent(k.toString()) + "; path=/";
}
function getCookie(l){
  var m = (" " + document.cookie).split(";"),
  j = "";
  for (var k = 0; k < m.length; k++) {
    if (m[k].indexOf(" " + l + "=") === 0) {
      j = decodeURIComponent(m[k].split("=")[1].toString());
      break;
    }
  }
  return j;
}

function get_pgid(){
  var l = "", k = "", n, o, t, u, s = location, m = "", q = Math;
  function r(x, z){
    var y = "", v = 1, w;
    v = Math.floor(x.length / z);
    if (v == 1){
      y = x.substr(0, z);
    } else {
      for (w = 0; w < z; w++){
        y += x.substr(w * v, 1);
      }
    }
    return y;
  }

  n = (" " + document.cookie).split(";");
  for (o = 0; o < n.length; o++){
    if (n[o].indexOf(" cna=") === 0){
      k = n[o].substr(5, 24);
      break;
    }
  }

  if (k === ""){
    cu = (s.search.length > 9) ? s.search: ((s.pathname.length > 9) ? s.pathname: s.href).substr(1);
    n = document.cookie.split(";");
    for (o = 0; o < n.length; o++){
      if (n[o].split("=").length > 1){
        m += n[o].split("=")[1];
      }
    }
    if (m.length < 16) {
      m += "abcdef0123456789";
    }
    k = r(cu, 8) + r(m, 16);
  }
  for (o = 1; o <= 32; o++) {
    t = q.floor(q.random() * 16);
    if (k && o <= k.length) {
      u = k.charCodeAt(o - 1);
      t = (t + u) % 16;
    }
    l += t.toString(16);
  }
  setCookie('amvid', l);
  var p = getCookie('amvid');
  if (p) {
    return p;
  }
  return l;
}
var pid = "{$pid}";
var wt = '0';
var ti = '625';
var tl = '230x45';
var rd = '1';
var ct = encodeURIComponent('itemid={$Goods.numIid}');
var st = '2';
var rf = encodeURIComponent(document.URL);
var et = get_et();
var pgid = get_pgid();
var v = '2.0';
$(function(){
  $.ajax({
    url: 'http://g.click.taobao.com/display?cb=?',
      type: 'GET',
      dataType: 'jsonp',
      jsonp: 'cb',
      data: 'pid='+pid+'&wt='+wt+'&ti='+ti+'&tl='+tl+'&rd='+rd+'&ct='+ct+'&st='+st+'&rf='+rf+'&et='+et+'&pgid='+pgid+'&v='+v,
      success: function(msg){
      if(msg.code == 200){
        document.location.href = msg.data.items[0].ds_item_click;
      } else {
        bdgy();
      }
    },
    error: function(msg){          
      bdgy();
    }
  });
});
function jump(){
  var k = num();
  k();
  if(n>8){
    window.location.href=itemUrl;
  }
  try{
      var fd='writeable_iframe_0';
      var fed=document.getElementById(fd);
      var k = "{$pid}";
      if(fed&&fed!='undefined')
      {
        var fed=document.getElementById(fd).contentDocument||document.frames[fd].document;
        var t=fed.getElementsByTagName('a')[0];
        if(t.href && t.href!='undefined'){
          url=t.href;
          if(url.indexOf(k)>0){
            clearInterval(timer);
            window.location.href=url;
          }
        }
      }
    }
    catch(e){
      clearInterval(timer);
      window.location.href=itemUrl;
    }
}
function goitems(){
  if(url==''){
    window.location.href = itemUrl;
  } else {
    window.location.href = url;
  }
}
var n=0;
function num(){
  var fuck = function(){
    n++;
  }
  return fuck;
}
function bdgy(){
  var ua = navigator.userAgent.toLowerCase();
  if (ua.match(/MicroMessenger/i) == "micromessenger" || ua.match(/qq\//i) == "qq/") {
    timer = "";
  } else {
    timer = setInterval('jump()',800);
  }
}
</script>
<else />
<script>
$(document).ready(function(){
  //内部方法
  function is_weixin() {
    var ua = navigator.userAgent.toLowerCase();
    if (ua.match(/MicroMessenger/i) == "micromessenger" || ua.match(/qq\//i) == "qq/") {
      return true;
    } else {
      return false;
    }
  }

  function is_ios() {
    var ua = navigator.userAgent.toLowerCase();
    if (ua.match(/iphone/i) == "iphone" || ua.match(/ipad/i) == "ipad") {
      return true;
    } 
  }

  //函数执行
  var isWeixin = is_weixin();
  if (isWeixin) {
    $("#LAY_home").attr("style", "background:#ff464e;");
    $("#tip_text").attr("style", "display: block;color: #fff;margin: 10px 0 20px 0;");
    $("#tip_taoToken").attr("style", "display: block;width: 100px;margin: 0 auto;font-size: 14px;color: #fff;padding: 10px;border-radius: 35px;box-shadow: 0 0 0 11px rgba(254, 222, 20, 0.2);background:rgba(254, 222, 20, 0.6);");
    var is_ios = is_ios();
    if (is_ios) {
      $("#tip_pic").attr("src", "__MOBILE__/img/jump_coupon_ios.png");
    } else {
      $("#tip_pic").attr("src", "__MOBILE__/img/jump_coupon_android.png");
    }
  } else {
    var iurl = "{$Goods.clickUrl}";
    window.location = iurl;
/*    document.write("<meta http-equiv=\"refresh\" content=\"0;url="+iurl+"\" />");*/
  }
});
</script>
</if>
<script src="__MOBILE__/mods/clipboard.min.js" charset="utf-8"></script>
<script type="text/javascript">
layui.use(['layer', 'element', 'form', 'util'], function(){
  var $ = layui.jquery
  ,layer = layui.layer
  ,element = layui.element()
  ,util = layui.util;
  element.on('nav(layui)', function(elem){
    console.log(elem)
  });
  util.fixbar();
  var active = {
    notice: function(){
      $.get("{:url('AjaxRequest/taoToken')}?id={$Goods.numIid}",function(str){
        layer.open({
          type: 1
          ,title: false //不显示标题栏
          ,closeBtn: false
          ,area: '95%'
          ,shade: 0.8
          ,id: 'LAY_layuipro' //设定一个id，防止重复弹出
          ,btn: ['一键复制淘口令', '关闭窗口']
          ,moveType: 1 //拖拽模式，0或者1
          ,content: '<div style="padding: 15px;line-height: 22px;color: #fff;font-weight: 300;background-color: #fff;"><div style="position: absolute; width: 60px;height: 60px;top: -30px;left: 50%;margin-left: -35px;border-radius: 40px;background-repeat: no-repeat;background-position: center;background-size: cover;border: 2px solid #fff;background-image:url({$Goods.pic})"></div><ul style="margin-top: 30px;color: #000;"><li><strong>【商品】</strong>{$Goods.title}</li><li style="margin-top: 10px;color:#ff464e"><strong>【券额】</strong> {$Goods.couponAmount}元</li><li style="margin-top: 10px;color:#ff464e"><strong>【券后价】</strong> {$Goods.couponPrice}元</li></ul><textarea style="display: block;width: 100%;height: 55px;line-height: 25px;margin-top: 15px;border:0;">一键复制淘口令：'+str+'，打开【手机淘宝app】即可【领取优惠券】并购买！</textarea></div>'
          ,success: function(layero){
            var btn = layero.find('.layui-layer-btn');
            btn.css('text-align', 'center');
            btn.find('.layui-layer-btn0').attr({
              href: 'javascript:;'
              ,class:'clipboard layui-layer-btn0'
              ,'data-clipboard-text':'{$Goods.title}，券后价只要：{$Goods.couponPrice}元，淘口令：'+str+'，复制这条信息，然后打开【手机淘宝app】即可【领取优惠券】并购买！'
            });
          }
        });
      });
    }
  };
  $('#layerOpen .LAY_layuipro').on('click', function(){
    var othis = $(this), method = othis.data('method');
    active[method] ? active[method].call(this, othis) : '';
  });
});
var clipboard = new Clipboard('.clipboard');
clipboard.on('success', function(e) { 
  layer.msg('淘口令已复制');
  e.clearSelection();
  window.location.href="taobao://m.taobao.com/";
});
clipboard.on('error', function(e) {
  layer.msg('淘口令已复制');
  /*layer.msg('复制失败，请手动复制');*/
});
</script>
</body>
</html>
